/**
 * @author nttdocomo
 */
seajs.config({
	alias : {
		'jquery' : 'jquery.min',
		'backbone' : 'backbone',
		'underscore' : 'underscore'
	},
	base : 'http://ui.example.com/js/',
	charset : 'utf-8'
});
TestCase("FormFieldTest", {
	testTemplateDefine : function() {
		seajs.use("http://ui.example.com/js/aries.js", function() {
			aries.augmentString('aries.templates.test_template',_.template('<input<% if(typeof(id)!=="undefined"){ %> id="<%=id%>"<%}%> type="<%=type%>"<% if(typeof(name)!=="undefined"){ %> name="<%=name%>"<%}%><% if(typeof(value)!=="undefined"){ %> value="<%=value%>"<%}%><% if(typeof(placeholder)!=="undefined"){ %> placeholder="{placeholder}"<%}%><% if(typeof(maxlength)!=="undefined"){ %> maxlength="{maxLength}"<%}%><% if(typeof(readonly)!=="undefined"){ %> readonly="readonly"<%}%><% if(typeof(disabled)!=="undefined"){ %> disabled="disabled"<%}%><% if(typeof(tabIndex)!=="undefined"){ %> tabIndex="{tabIdx}"<%}%><% if(typeof(fieldStyle)!=="undefined"){ %> style="{fieldStyle}"<%}%> class="<%=fieldCls%> <%=typeCls%> <%=editableCls%>" autocomplete="off"/>'));
			aries.view("aries.view.TestTemplate",Backbone.View.extend());
			assertEquals("aries.view.TestTemplate's tempalte", aries.templates.test_template, aries.view.TestTemplate._template);
			assertTrue("the value is empty but allow empty", aries.isEmpty("",1));
			assertFalse("do not allow value is empty", aries.isEmpty(""));
			assertFalse("the value is not empty", aries.isEmpty("1"));
		})
	},
	testBaseInputField : function() {
		seajs.use("http://ui.example.com/js/form/field/text.js", function() {
			var $container = $('<div/>').appendTo($(document.body))
			var text = new aries.form.field.Text({
				container : $container,
				name : 'textfield1',
				fieldLabel : 'Text field',
				value : 'Text field value'
			});
			assertTagName("this will be an input", "input", text.inputEl[0]);
			assertClassName("this input's class", "g-form-field", text.inputEl[0]);
			assertClassName("this input's class", "g-form-text", text.inputEl[0]);
			assertEquals("this input name ", "textfield1", text.inputEl.attr("name"));
			text.activeError = "error";
			assertEquals("error", text.activeError, text.getActiveError());
		})
	},
	testCheckBox : function() {
		seajs.use("http://ui.example.com/js/form/field/checkbox.js", function() {
			var $container = $('<div/>').appendTo($(document.body))
			var checkbox = new aries.form.field.Checkbox({
				container : $container,
				name : 'checkbox1',
				fieldLabel: 'Checkbox',
				boxLabel: 'box label'
			});
			assertTagName("this will be an input", "input", checkbox.inputEl[0]);
			assertEquals("there is to label in container", 2, $container.find("label").length)
			assertClassName("this input's class", "g-form-checkbox", checkbox.inputEl[0]);
		})
	}
});
